
package com.primeton.eos.oss.model.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.eos.system.utility.PageResultList;

import com.eos.data.datacontext.DataContextManager;
import com.eos.data.datacontext.IMUODataContext;

import com.primeton.eos.oss.model.dao.AfcUserDao;
import com.primeton.eos.oss.model.newdataset.AfcUser;

@Service
public class AfcUserService {

    @Autowired
    private AfcUserDao afcUserDao;


    public PageResultList<AfcUser> queryAfcUsersWithPage(String code,  int pageSize, int pageIndex) {
        //TODO 记录日志
        return afcUserDao.queryAfcUsersWithPage(code,  pageSize, pageIndex);
    }

    public AfcUser getAfcUserById(String id) {
        //TODO 记录日志
        return afcUserDao.getEntity(AfcUser.QNAME, id);
    }

    @Transactional
    public void createAfcUser(AfcUser afcUser) {
        //TODO 记录日志
    	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        afcUser.set("createUser", userName);
        afcUser.set("createTime", new Date());
        afcUser.set("updateUser", userName);
        afcUser.set("updateTime", new Date());

        afcUserDao.getPrimaryKey(afcUser);
        afcUserDao.insertEntity(afcUser);
    }
    
    @Transactional
    public void modifyAfcUser(AfcUser afcUser) {
        //TODO 记录日志
     	String userName = "";
		IMUODataContext muo = DataContextManager.current().getMUODataContext();
		if (muo != null) {
			userName = muo.getUserObject().getUserName();
		}
        afcUser.set("updateUser", userName);
        afcUser.set("updateTime", new Date());
 
        afcUserDao.updateEntity(afcUser);
    }
    
     @Transactional
    public void removeAfcUser(AfcUser[] afcUser) {
        //TODO 记录日志
        afcUserDao.deleteEntity(afcUser);
    }

}





